import  {Route, Redirect}  from 'react-router-dom'
import  {getToken}  from '@/utils'

const   AuthRoute = ({component:Component,...reset})=>{
   return (
    <Route {...reset}   
    
      render={(props)=>{
            // 判断是否登录
            if(!getToken()) {
               // 未登录
                 return (  <Redirect   to={{pathname:'/login', state:{from: props.location.pathname}}} />)
            }  else  {
               return (  <Component/>)
            }
      }}
    ></Route>

   )
}


export  { AuthRoute}